# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Yiyao Yu <yuydevel at protonmail dot com>
# Contributor: Moritz Lipp <mlq@pwmt.org>

pkgname=bear
pkgver=3.1.2
pkgrel=1
pkgdesc='A tool to generate compilation database for clang tooling'
arch=('loong64' 'x86_64')
url='https://github.com/rizsotto/Bear'
license=('GPL3')
depends=(
  'glibc'
  'gcc-libs'
  'grpc'
  'libgrpc++.so'
  'fmt'
  'spdlog'
  'nlohmann-json'
  'abseil-cpp'
  'protobuf'
  'openssl'
  'c-ares'
  're2'
)
makedepends=(
  'git'
  'cmake'
  'gtest'
  'python'
  'llvm'
)
_commit='0c48ae75892c8ace741a87209e7293c50687c9f0'
source=("$pkgname::git+$url.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags
}

# XXX if this is moved to build, tests fail.
# there must be some environment variables that
# are discarded inbetween functions.
prepare() {
  cmake \
    -B build \
    -S "$pkgname" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_SYSCONFDIR=/etc \
    -DCMAKE_INSTALL_LIBEXECDIR="lib/$pkgname"
}

build() {
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
